<?php $__env->startSection('title'); ?><?php echo Lang::get('users.messages'); ?> - <?php $__env->stopSection(); ?>

<?php $__env->startSection('css_style'); ?>
<link href="<?php echo URL::asset('public/css/jquery.fs.picker.min.css'); ?>" rel="stylesheet">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?> 
     
     <?php 
     
     // ** Admin Settings ** //
     $settings = AdminSettings::first();
	 
	 // ** Data User logged ** //
     $user = Auth::user();

     ?>
     
<div class="col-md-4">
 
 <button type="button" class="btn btn-default btn-block btn-border btn-lg show-toogle" data-toggle="collapse" data-target=".responsive-side" style="margin-bottom: 20px;">
		   <i class="fa fa-bars"></i>
		</button>
		
 <div class="responsive-side collapse">    	
    <?php echo $__env->make('includes.user-card', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	
	<?php echo $__env->make('includes.sidebar_edit_user', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

	<?php echo $__env->make('includes.ads', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	
	</div>
			
 </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('sidebar'); ?>
<div class="col-md-8">
	
	<!--********* panel panel-default ***************-->
     	<div class="panel panel-default">
		  <div class="panel-heading grid-panel-title">
		  	
		  	<span class="btn-block">
		  		<?php echo Lang::get('users.messages'); ?>

		  	</span><!-- **btn-block ** -->
		  
		  </div><!-- ** panel-heading ** -->
		  
		  <div class="content">
		
		  	<?php foreach( $message as $msg ): ?>
		  	 
		  	 <?php
		  	 
		  	 if( $msg->last()->from_user_id == Auth::user()->id && $msg->last()->to()->id != Auth::user()->id ){
		  	 	$avatar   = $msg->last()->to()->avatar;
				$name     = $msg->last()->to()->name;
				$userID   = $msg->last()->to()->id;
				$username = $msg->last()->to()->username;
				$iconUndo = '<i class="icon-undo2 myicon-right"></i> ';
				
		  	 } else if( $msg->last()->from_user_id == Auth::user()->id   ){
		  	 	$avatar   = $msg->last()->to()->avatar;
				$name     = $msg->last()->to()->name;
				$userID   = $msg->last()->to()->id;
				$username = $msg->last()->to()->username;
				$iconUndo = null;
		  	 } else{
		  	 	$avatar   = $msg->last()->from()->avatar;
				$name     = $msg->last()->from()->name;
				$userID   = $msg->last()->from()->id;
				$username = $msg->last()->from()->username;
				$iconUndo = null;
		  	 }
		  	 
		  	 if( $msg->last()->attach_file != '' ) {
		  	 	$attach = '<i class="icon-attachment myicon-right"></i>';
		  	 } else {
		  	 	$attach = null;
		  	 }
			 /* New - Readed */
				 if( $msg->last()->status == 'new' && $msg->last()->from()->id != Auth::user()->id )  {
				 	$styleStatus = ' unread-msg'; 
				 } else {
					 $styleStatus = null; 
				 }
		  	  ?>
				<li class="li-group-msg hoverList" >
	      		<a href="<?php echo URL::to('/'); ?>/messages/<?php echo $userID.'-'.$username; ?>" class="see_msg list-group-item border-group<?php echo $styleStatus; ?>">
	                         <div class="media">
	                            <div class="pull-left">
	                               <img src="<?php echo URL::asset('public/avatar'); ?>/<?php echo $avatar; ?>" alt="Image" class="border-image-profile-2 media-object img-circle image-dropdown">
	                            </div>
	                            <div class="media-body clearfix">
	                               <div class="pull-right small">
	                               	<span class="timestamp timeAgo myicon-right" data="<?php echo date('c',strtotime( $msg->last()->created_at ) ); ?>"></span>
	                               	</div>
	                               
	                               <div class="media-nowrap">
	                               	<strong class="media-heading"><?php echo e( $name ); ?></strong>
	                               </div>
	                               
	                               <p class="text-col">
	                               	
	                                  <small><?php echo $iconUndo.$attach; ?><?php echo e( $msg->last()->message ); ?></small>
	                               </p>
	                            </div>
	                         </div>
	                      </a>
	          	       </li>
	          	      <?php endforeach; ?> 
	   </div><!-- /End content -->
	          	
	          	<?php if( $message->count() == 0 ): ?>
          <div class="panel-body">
          	<h3 class="margin-top-none text-center no-result color-no-result">
	    	- <?php echo Lang::get('misc.no_messages'); ?> -
	    	</h3>
          </div>
          
          <?php endif; ?>
   </div><!-- Panel Default -->

          
          <?php if( $message->getLastPage() > 1 && Input::get('page') <= $message->getLastPage() ): ?>
    		
	    		<div class="btn-group paginator-style">
	        		<?php echo $message->links(); ?> 
	        	</div>
	        	
    		<?php endif; ?>
</div><!-- /End col md -->

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>